package com.chargerlink.echarger.vo;

import java.io.Serializable;

public class ResponseDataVo<T> extends ResponseBase implements Serializable {

    private static final long serialVersionUID = -8389534598865802502L;
    private T data;



    public ResponseDataVo(T data, Integer code, String message) {
        super(code, message);
        this.data = data;
    }

    public ResponseDataVo(T data, Integer code, String message, Pager pager) {
        super(code, message);
        this.setPager(pager);
        this.data = data;
    }

    public static <T> ResponseDataVo<T> success(T t, Pager pager) {
        return new ResponseDataVo<T>(t, ResponseConstant.SUCCESS_CODE, "成功", pager);
    }


    public static <T> ResponseDataVo<T> success(T t) {
        return new ResponseDataVo<T>(t, ResponseConstant.SUCCESS_CODE, "成功");
    }

    public static <T> ResponseDataVo<T> error() {
        return error("失败");
    }



    public static <T> ResponseDataVo<T> logicError(String message) {
        return new ResponseDataVo<T>(null, Integer.valueOf(3), message);
    }

    public static <T> ResponseDataVo<T> sysError(String message) {
        return new ResponseDataVo<T>(null, Integer.valueOf(4), message);
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static ResponseDataVo error(String message) {
        ResponseDataVo resp = new ResponseDataVo(null, ResponseConstant.ERROR_CODE, null);
        resp.setError(message);
        return resp;
    }
}